/*******************************************************************************
 * Copyright (c) 2011 Olexandr V. Shaposhnikov.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Olexandr V. Shaposhnikov - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.funkyroach.use.ui.text;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;

public class USPartitionTokenScanner extends RuleBasedPartitionScanner {
    public USPartitionTokenScanner() {

        IToken usCommentToken = new Token(IUSPartitionTokens.US_COMMENT_TYPE);
        IToken usStringToken = new Token(IUSPartitionTokens.US_STRING_TYPE);

        List<IPredicateRule> rules = new ArrayList<IPredicateRule>();
        rules.add(new MultiLineRule("/*", "*/", usCommentToken));
        rules.add(new SingleLineRule("//", "", usCommentToken));
        rules.add(new SingleLineRule("\"", "\"", usStringToken, '\\'));
        rules.add(new SingleLineRule("'", "'", usStringToken, '\\'));

        setPredicateRules(rules.toArray(new IPredicateRule[] {}));
    }
}
